import React from 'react'
import {
  observer,
  inject,
} from 'mobx-react'

import PropTypes from 'prop-types'
import { AppState } from '../../store/app-state'


@inject('appState') @observer
export default class TopicList extends React.Component {
  constructor() {
    super()
    this.changeName = this.changeName.bind(this)
  }


  changeName(event) {
    this.props.appState.changeName(event.target.value)
  }

  render() {
    return (
      <div>
        <input type="text" onChange={this.changeName} />
        <span>
          {this.props.appState.msg}
        </span>
      </div>
    )
  }
}
// 验证数据类型(验证object是没有必要的)
TopicList.propTypes = {
  appState: PropTypes.instanceOf(AppState).isRequired,
}
